<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateShopBusinessTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_business', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('shopId')->default(0)->comment('门店id');
            $table->string('deliveryType', 56)->default('')->comment('投放类型');
            $table->string('deliveryTime', 12)->default('')->comment('投放开始时间');
            $table->string('shopType', 32)->default('')->comment('门店类型');
            $table->string('shopName', 255)->default('')->comment('门店名称');
            $table->unsignedInteger('shopCode')->default(0)->comment('门店编码');
            $table->string('region', 32)->default('')->comment('区域');
            $table->string('date', 12)->default('')->comment('日期');
            $table->unsignedInteger('orderNum')->default(0)->comment('订单量');
            $table->string('newOpen', 3)->default('')->comment('是否本月新开 - 不确定类型');
            $table->decimal('dailyManpower', 5)->default(0)->comment('日人工');
            $table->decimal('dailyEnergy', 4)->default(0)->comment('日能源');
            $table->decimal('roi', 4)->default(0)->comment('roi');
            $table->decimal('estimatedProfit', 6)->default(0)->comment('预估利润');
            $table->decimal('openMonthLong', 7)->default(0)->comment('开业时常（月）');
            $table->unsignedInteger('openDaysLong')->default(0)->comment('开业时常（天）');
            $table->decimal('shopArea', 5)->default(0)->comment('门店面积');
            $table->decimal('orderTurnover', 7)->default(0)->comment('订单营业额');
            $table->decimal('orderOfferAmount', 7)->default(0)->comment('订单优惠金额');
            $table->string('orderReceivedAmount', 7)->default(0)->comment('订单实收金额');
            $table->unsignedInteger('staffNum')->default(0)->comment('员工人数');
            $table->string('province', 12)->default('')->comment('省份');
            $table->string('city', 12)->default('')->comment('城市');
            $table->decimal('takeawayOrderTurnover', 7)->default(0)->comment('外卖订单营业额');
            $table->decimal('takeawayOrderOfferAmount', 7)->default(0)->comment('外卖订单优惠金额');
            $table->decimal('takeawayOrderReceivedAmount', 7)->default(0)->comment('外卖订单实收金额');
            $table->decimal('canteenOrderTurnover', 7)->default(0)->comment('堂食订单营业额');
            $table->decimal('canteenOrderOfferAmount', 7)->default(0)->comment('堂食订单优惠金额');
            $table->decimal('canteenOrderReceivedAmount', 7)->default(0)->comment('堂食订单实收金额');
            $table->decimal('canteenEstimatedProfit', 7)->default(0)->comment('堂食预估利润');
            $table->decimal('takeawayEstimatedProfit', 7)->default(0)->comment('外卖预估利润');
            $table->unsignedInteger('canteenOrderNum')->default(0)->comment('堂食订单量');
            $table->unsignedInteger('takeawayOrderNum')->default(0)->comment('外卖订单量');
            $table->string('openBusinessDate', 12)->default('')->comment('开业日期');
            $table->string('closureTime', 12)->default('')->comment('闭店时间');
            $table->string('franchiseeName', 64)->default('')->comment('加盟商 - 隐私数据');
            $table->decimal('dailyRent', 6, 2)->default(0)->comment('日房租');
            $table->decimal('rent', 7, 2)->default(0)->comment('房租');
            $table->string('district', 32)->default('')->comment('区县');
            $table->string('shopActiveStatus', 32)->default('')->comment('门店活跃状态');
            $table->string('status', 32)->default('')->comment('状态');
            $table->unsignedInteger('manpower')->default(0)->comment('人工');
            $table->decimal('preservationPoint', 7, 2)->default(0)->comment('保本点');
            $table->unsignedSmallInteger('monthBusinessDays')->default(0)->comment('月营业天数');
            $table->decimal('dailyIncome', 7, 2)->default(0)->comment('日均实收');
            $table->unsignedInteger('monthDays')->default(0)->comment('实际月天数');
            $table->string('thisYearClose', 4)->default('')->comment('是否本年闭店');
            $table->string('shopAddress', 255)->default('')->comment('店铺地址');
            $table->string('cityGrade', 8)->default('')->comment('城市等级');
            $table->string('roiGrade', 32)->default('')->comment('ROI分类');
            $table->string('franchiseeRealName', 64)->default('')->comment('加盟商真名');
            $table->decimal('dailyRentCost', 6)->default(0)->comment('日房租成本');
            $table->string('headOperations', 32)->default('')->comment('运营负责人');
            $table->string('privateDomain', 32)->default('')->comment('私域');
            $table->unsignedInteger('mtOrderNum')->default(0)->comment('美团订单量');
            $table->unsignedInteger('elmOrderNum')->default(0)->comment('饿了么订单量');
            $table->string('agencyOperationStatus', 32)->default('')->comment('代运营状态');
            $table->string('averageDailyProfit', 32)->default('')->comment('日均利润');
            $table->unsignedSmallInteger('receivedGrade')->default(0)->comment('实收分级');
            $table->unsignedSmallInteger('profitGrade')->default(0)->comment('利润分级');
            $table->decimal('weightRoi', 3, 2)->default(0)->comment('加权ROI');
            $table->string('loss', 8)->default('')->comment('是否亏损');
            $table->string('shopGrade', 16)->default('')->comment('门店分级');
            $table->string('siteLocationType', 32)->default('')->comment('选址分类');
            $table->decimal('elmRating', 3, 2)->default(0)->comment('饿了么评分');
            $table->decimal('mtRating', 3, 2)->default(0)->comment('美团评分');
            $table->string('cashierSystem', 32)->default('')->comment('收银系统');
            $table->unsignedInteger('elmShopId')->default(0)->comment('waimaiShopId-饿');
            $table->string('elmShopName', 120)->default('')->comment('waimaiShopName-饿');
            $table->unsignedInteger('mtShopId')->default(0)->comment('waimaiShopId-美');
            $table->string('mtShopName', 120)->default('')->comment('waimaiShopName-美');
            $table->string('takeawayOpenTime', 10)->default('')->comment('外卖介入时间');
            $table->string('takeawayShopStatus', 16)->default('')->comment('外卖新店判断');
            $table->string('performanceRange', 16)->default('')->comment('业绩区间');
            $table->string('activityType', 16)->default('')->comment('活动类型');
            $table->string('shopAreaType', 16)->default('')->comment('铺位类型');
            $table->unsignedInteger('takeawayBusinessDays')->default(0)->comment('外卖营业天数');
            $table->decimal('turnoverAmount', 8)->default(0)->comment('近30天营业金额');
            $table->decimal('orderAmount', 8)->default(0)->comment('近30天订货金额');
            $table->decimal('orderRatio', 5)->default(0)->comment('订货比');
            $table->unsignedInteger('lastCruiseTime')->default(0)->comment('上次巡店时间');

            $table->unsignedInteger('createdAt')->default(0);

            $table->index('shopId', 'idx_shopId');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '门店营业数据';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_business');
    }
}
